<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text">
<input type="button" value="表情包" onclick="f(1)" >
<input type="button" value="图片" onclick="f(2)" >
<script>
    /*let img = document.createElement("img");
    img.src="tp.jpg"
    document.body.append(img);*/
    function f(x){
        /*三目运算--条件？值1:值2*/
        let sz=document.querySelector("input")
        for(var i=0;i<sz.value;i++){
            let src = x==1?"tp.jpg":"bqg.jpg"
            let img = document.createElement("img")
            img.src=src;
            document.body.append(img);
        }

    }

</script>




</body>
</html>